<template>
  <div class="box">
    <div class="box_content">
      <div>
        活动状态
        <template>
          <el-select placeholder="请选择" v-model="finsh">
            <el-option>未完成</el-option>
            <el-option>进行中</el-option>
            <el-option>已完成</el-option>
          </el-select>
        </template>
      </div>
      <div>
        <template>
          <span> 商品类型</span>
          <el-select v-model="value" clearable placeholder="请选择">
            <el-option
              v-for="item in obj"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </template>
      </div>
      <div>
        拼团名称<el-input
          v-model="names"
          placeholder="请输入拼团名称关键字"
        ></el-input>
      </div>
      <div>
        <el-button type="primary" icon="el-icon-search" @click="onSearch"
          >搜索</el-button
        >
        <el-button type="primary" icon="el-icon-delete" @click="onRemove"
          >重置</el-button
        >
      </div>
    </div>
    <div class="btn">
      <el-button type="primary" @click="gonew">新增拼团活动</el-button>
    </div>

    <div class="tit">
      <el-table :data="tableData" style="width: 100%" border>
        <el-table-column prop="spell_name" label="拼团名称"> </el-table-column>
        <el-table-column prop="name" label="参团商品"> </el-table-column>
        <el-table-column label="有效期">
          <template slot-scope="scope">
            {{ scope.row.end_time | formatDate }}
          </template>
        </el-table-column>
        <el-table-column prop="status" label="活动状态">
          <template slot-scope="scope">
            {{ scope.row.status === 2 ? "未开始" : "已完成" }}
          </template>
        </el-table-column>
        <el-table-column prop="group_order_num" label="成团订单数？">
        </el-table-column>
        <el-table-column prop="group_order_price" label="成团订单金额？">
        </el-table-column>
        <el-table-column label="操作"> </el-table-column>
      </el-table>
    </div>
    <div>
      <div class="block">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage4"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="100"
          layout="total, sizes, prev, pager, next, jumper"
          :total="0"
        >
        </el-pagination>
      </div>
    </div>
  </div>
</template>
<script>

import { getlist } from '../../api/api4'
export default {
  data() {
    return {
      finsh: '',
      input: '',
      tableData: [],
      copylist: [],
      currentPage1: 5,
      currentPage2: 5,
      currentPage3: 5,
      currentPage4: 4,
      type: '',
      names: '',
      obj: this.$store.state.options,
      value: ''
    }
  },
  mounted() {
    getlist().then(res => {
      console.log(res)
      this.tableData = res.data.list
      this.copylist = res.data.list
    })
  },
  methods: {
    gonew() {
      this.$router.push({ name: 'newtitle' })
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`)
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`)
    },

    // 搜索
    onSearch() {
      this.tableData = this.copylist.filter(item => {
        return item.spell_name.includes(this.names)
      })
    },
    // 重置
    onRemove() {
      this.names = ''
      this.onSearch()
    }
  }
}
</script>

<style lang="scss" scope>
.box {
  width: 100%;
  height: 60px;
  border-top: 1px solid black;
}
.box_content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.box_content div {
  width: 60%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-left: 10px;
}
.btn {
  margin: 30px 0;
}
.title {
  margin-top: 10px;
  box-shadow: 0 0 8px #ccc;
  color: black;
}
.cell {
  color: rgba(0, 0, 0, 0.733);
}
</style>
